package com.tanhua.api.impl.mongo;

import com.tanhua.api.mongo.SubjectApi;
import com.tanhua.domain.mongo.Subject;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

import java.util.List;
@Service
public class SubjectApiImpl implements SubjectApi {

    @Autowired
    MongoTemplate mongoTemplate;

    @Override
    public List<Subject> getSubjectByQuestionId(String questionId) {
        Query query = new Query(Criteria.where("questionId").is(questionId));
        List<Subject> subjectList = mongoTemplate.find(query, Subject.class);
        return subjectList;
    }
}
